﻿@model GolfLeague.ViewModels.RoundViewModel

@{
    ViewBag.Title = "MatchesWidget";
}

<fieldset>
<legend>Tee Box: @Model.Round.TeeBox.TeeBoxName</legend>
<table>
    <tr>
        <th>
            MatchTime
        </th>
        <th>
            Team A
        </th>
        <th>
            Team B
        </th>
    </tr>

@foreach (var item in Model.Matches) {
    <tr>
        <td>
            @if (item.MatchTime.Hour < 12)
            {
                @String.Format("{0:h':'mm} {1}", item.MatchTime, "AM")
            }
            else
            {
                @String.Format("{0:h':'mm} {1}", item.MatchTime.Subtract(new TimeSpan(12,0,0)), "PM")
            }
        </td>
        <td>
            @item.Team1.TeamName<br /> (@item.Team1.PlayerTeams.First().Player.LastName/@item.Team1.PlayerTeams.Last().Player.LastName)
        </td>
        <td>
            @item.Team2.TeamName<br /> (@item.Team2.PlayerTeams.First().Player.LastName/@item.Team2.PlayerTeams.Last().Player.LastName)
        </td>
    </tr>
}

</table>
</fieldset>